/*
 *  sci_server_lib.h
 *  PointerTest
 *
 *  Created by Jonatan Werpers on 5/3/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */


#define MULTI_CHIP_SETUP 0 


#if MULTI_CHIP_SETUP
/* CHIP ID */
#define CHIP_ID "A"
#endif

#define MAX_WORD_LENGTH 10
//Including \0 string termination.

#define IN_BUF 15 //Size of input buffer.



#define incInPtr(ptr) if(++ptr > inBufferEnd) ptr = inBuffer;
#define incOutPtr(ptr) if(++ptr > putBufferEnd) ptr = outBuffer;

#define isWS(ch) (ch == '\n' || ch == ' ')
#define NEWLINE '\n'

//Function prototypes
void cmdHelp();
void cmdGet();
void cmdSet();
void cmdVars();
int * getVar();
void inputError(char *);
void readNextCommand();
int getNextWord();
char * compareToBuffer(char *);
void writeToBuffer(char *);



struct Command{
	char name[MAX_WORD_LENGTH];
	void (*functionPtr)();
};

struct Variable{
	char name[MAX_WORD_LENGTH];
	int *varPtr;
};


char inBuffer[IN_BUF];
char const *inBufferEnd;


char *rxPtr; //Points to where the next recieved character will be stored
char *readPtr;	//Points to where the next unread character is.
int cmdCounter;


#define NR_CMD 4
struct Command cmdList[NR_CMD];
#define NR_VAR 3
struct Variable varList[NR_VAR];
